/* eslint-disable indent */
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import ApiConstants from "@/constants/API.constants"

Vue.prototype.API = ApiConstants

/* Router Modules */
// import componentsRouter from './modules/components'
// import chartsRouter from './modules/charts'
// import tableRouter from './modules/table'
// import nestedRouter from './modules/nested'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [{
  path: '/redirect',
  component: Layout,
  hidden: true,
  children: [{
    path: '/redirect/:path*',
    component: () => import('@/views/redirect/index')
  }]
},
{
  path: '/login',
  component: () => import('@/views/login/index'),
  hidden: true
},
{
  path: '/auth-redirect',
  component: () => import('@/views/login/auth-redirect'),
  hidden: true
},
{
  path: '/404',
  component: () => import('@/views/error-page/404'),
  hidden: true
},
{
  path: '/401',
  component: () => import('@/views/error-page/401'),
  hidden: true
},
{
  path: '/',
  component: Layout,
  redirect: '/dashboard',
  children: [
    {
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      name: 'dashboard',
      meta: { title: '首页', icon: 'dashboard', affix: true }
    }
  ]
},
{
  path: '/driver',
  component: Layout,
  redirect: '/driver',
  alwaysShow: true, // will always show the root menu
  name: 'driver',
  meta: {
    title: '用户管理',
    icon: 'user',
    activeMenu: '/driver'

  },
  children: [
    {
      path: 'driver',
      component: () => import('@/views/driver/index'),
      name: 'driver',
      meta: {
        title: '司机管理'
      }
    },
    {
      path: 'owner',
      component: () => import('@/views/owner/index'),
      name: 'owner',
      meta: {
        title: '货主管理'
      }
    },
    {
      path: 'captain',
      component: () => import('@/views/captain/index'),
      name: 'captain',
      meta: {
        title: '车队长管理'
      }
    },
    {
      path: 'car',
      component: () => import('@/views/car/index'),
      name: 'car',
      meta: {
        title: '车辆管理'
      }
    },
    {
      path: 'cards',
      component: () => import('@/views/cards/index'),
      name: 'cards',
      meta: {
        title: '银行卡管理'
      }
    }
  ]
},
{
  path: '/goods',
  component: Layout,
  redirect: '/goods/index',
  name: 'goods',
  meta: {
    title: '货单管理',
    icon: 'component'
  },
  children: [
    {
      path: 'address',
      component: () => import('@/views/address/index'),
      name: 'shop',
      meta: {
        title: '地址管理',
        affix: true,
        activeMenu: '/goods'

      }
    },
    {
      path: 'goods',
      component: () => import('@/views/goods/index'),
      name: 'cards',
      meta: {
        title: '我的货单',
        activeMenu: '/goods'

      }
    }
  ]
},
{
  path: '/order',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/order/index'),
    name: 'order',
    meta: {
      title: '订单管理',
      icon: 'list',
      affix: false,
      activeMenu: '/order'

    }
  }]
},
{
  path: '/payManage',
  component: Layout,
  redirect: '/payManage/index',
  name: 'payManage',
  meta: {
    title: '财务管理',
    icon: 'money'
  },
  children: [
    {
      path: 'payManage',
      component: () => import('@/views/payManage/index'),
      name: 'shop',
      meta: {
        title: '结算管理',
        affix: true,
        activeMenu: '/payManage'

      }
    },
    {
      path: 'withDraw',
      component: () => import('@/views/withDraw/index'),
      name: 'cards',
      meta: {
        title: '提现管理',
        activeMenu: '/withDraw'

      }
    },
    {
      path: 'taxReceiptManage',
      component: () => import('@/views/taxReceiptManage/index'),
      name: 'cards',
      meta: {
        title: '开票管理',
        activeMenu: '/taxReceiptManage'

      }
    },
    {
      path: 'tradeManage',
      component: () => import('@/views/tradeManage/index'),
      name: 'cards',
      meta: {
        title: '交易管理',
        activeMenu: '/tradeManage'

      }
    }
  ]
},
{
  path: '/dataV',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/dataV/index'),
    name: 'dataV',
    meta: {
      title: '数据统计',
      icon: 'table',
      affix: true,
      activeMenu: '/dataV'

    }
  }]
},
{
  path: '/cooperation',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/cooperation/index'),
    name: 'cooperation',
    meta: {
      title: '油站管理',
      icon: 'table',
      affix: true,
      activeMenu: '/cooperation'

    },
    hidden: true

  }]
},
{
  path: '/agentVerify',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/agentVerify/index'),
    name: 'agentVerify',
    meta: {
      title: '每日对账',
      icon: 'table',
      affix: true,
      activeMenu: '/agentVerify'

    },
    hidden: true

  }]
},
{
  path: '/daoZhang',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/daoZhang/index'),
    name: 'daoZhang',
    meta: {
      title: '到账记录',
      icon: 'money',
      affix: false,
      activeMenu: '/daoZhang'

    },
    hidden: true

  }]
},
{
  path: '/getMoney',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/getMoney/index'),
    name: 'getMoney',
    meta: {
      title: '提现记录',
      icon: 'component',
      affix: false,
      activeMenu: '/getMoney'

    },
    hidden: true

  }]
},
{
  path: '/driverDetail',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/driverDetail/index'),
    name: 'driverDetail',
    meta: {
      title: '司机详情',
      icon: 'peoples',
      affix: false,
      activeMenu: '/tradeUserList'

    },
    hidden: true

  }]
},
{
  path: '/mainCard',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/mainCard/index'),
    name: 'mainCard',
    meta: {
      title: '主卡列表',
      icon: 'peoples',
      affix: false,
      activeMenu: '/shop'

    },
    hidden: true

  }]
},
{
  path: '/daughterCard',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/daughterCard/index'),
    name: 'daughterCard',
    meta: {
      title: '子卡列表',
      icon: 'peoples',
      affix: false,
      activeMenu: '/shop'

    },
    hidden: true

  }]
},
{
  path: '/bankCard',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/bankCard/index'),
    name: 'bankCard',
    meta: {
      title: '详情',
      icon: 'peoples',
      affix: false,
      activeMenu: '/bankCard'

    },
    hidden: true

  }]
},
{
  path: '/subCard',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/subCard/index'),
    name: 'bankCard',
    meta: {
      title: '详情',
      icon: 'peoples',
      affix: false,
      activeMenu: '/subCard'

    },
    hidden: true

  }]
},
{
  path: '/cooperationDetail',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/cooperationDetail/index'),
    name: 'cooperationDetail',
    meta: {
      title: '站点详情',
      icon: 'peoples',
      affix: false,
      activeMenu: '/cooperation'

    },
    hidden: true

  }]
},
{
  path: '/cooperationDetail2',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/cooperationDetail2/index'),
    name: 'cooperationDetail2',
    meta: {
      title: '站点详情',
      icon: 'peoples',
      affix: false,
      activeMenu: '/pfTransfer'

    },
    hidden: true

  }]
},
{
  path: '/tradesList',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/tradesList/index'),
    name: 'tradesList',
    meta: {
      title: '交易记录',
      icon: 'list',
      affix: false,
      activeMenu: '/tradesList'

    },
    hidden: true

  }]
},

{
  path: '/smsList',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/smsList/index'),
    name: 'smsList',
    meta: {
      title: '短信发送记录',
      icon: 'list',
      affix: false,
      activeMenu: '/smsList'

    },
    hidden: true

  }]
},
{
  path: '/agentVerifyCoo',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/agentVerifyCoo/index'),
    name: 'bankCard',
    meta: {
      title: '详情',
      icon: 'peoples',
      affix: false,
      activeMenu: '/agentVerifyCoo'

    },
    hidden: true

  }]
},
// {
//   path: '/walletDetail',
//   component: Layout,
//   children: [{
//     path: '',
//     component: () => import('@/views/walletDetail/index'),
//     name: 'walletDetail',
//     meta: {
//       title: '钱包明细',
//       icon: 'money',
//       affix: true,
//       activeMenu: '/walletDetail'

//     }
//   }]
// },

// {
//   path: '/down',
//   component: Layout,
//   children: [{
//     path: '',
//     component: () => import('@/views/down/index'),
//     name: 'down',
//     meta: {
//       title: '我的导出',
//       icon: 'excel',
//       affix: true,
//       activeMenu: '/down'
//     },
//     // hidden: true,
//     noCache: true
//   }]
// },

{
  path: '/info',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/info/index'),
    name: 'info',
    meta: {
      title: '个人中心',
      icon: 'user',
      affix: false,
      activeMenu: '/info'
    },
    hidden: true

  }]
},
{
  path: '/rateManage',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/rateManage/index'),
    name: 'rateManage',
    meta: {
      title: '折扣设置',
      icon: 'peoples',
      affix: false,
      activeMenu: '/cooperation'
    },
    hidden: true,
    noCache: true
  }]
},
{
  path: '/imgManage',
  component: Layout,
  children: [{
    path: '',
    component: () => import('@/views/imgManage/index'),
    name: 'imgManage',
    meta: {
      title: '图片管理',
      icon: 'peoples',
      affix: false,
      activeMenu: '/cooperation'
    },
    hidden: true,
    noCache: true
  }]
}
  // {
  //   path: '/img/:src(\\d+)',
  //   component: Layout,
  //   children: [{
  //     path: '',
  //     component: () => import('@/views/img/index'),
  //     name: 'img',
  //     meta: {
  //       title: '图片上传',
  //       icon: 'peoples',
  //       affix: true,
  //       activeMenu: '/cooperation'
  //     },
  //     hidden: true,
  //     noCache: true
  //   }]
  // },
  // {
  //   path: '/guide',
  //   component: Layout,
  //   redirect: '/guide/index',
  //   children: [{
  //     path: 'index',
  //     component: () => import('@/views/guide/index'),
  //     name: 'Guide',
  //     meta: {
  //       title: 'guide',
  //       icon: 'guide',
  //       noCache: true
  //     }
  //   }]
  // },
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  // {
  //   path: '/user',
  //   component: Layout,
  //   children: [{
  //     path: '',
  //     component: () => import('@/views/user/index'),
  //     name: 'user',
  //     meta: {
  //       title: '省代管理',
  //       icon: 'peoples',
  //       affix: true,
  //       activeMenu: '/user',
  //       roles: ['admin']
  //     }
  //   }]
  // },
  // {
  //   path: '/codeManage',
  //   component: Layout,
  //   children: [{
  //     path: '',
  //     component: () => import('@/views/codeManage/index'),
  //     name: 'codeManage',
  //     meta: {
  //       title: '验证码',
  //       icon: 'list',
  //       affix: true,
  //       activeMenu: '/codeManage',
  //       roles: ['admin']
  //     }
  //   }]
  // },
  {
    path: '/user1',
    component: Layout,
    redirect: '/user/index',
    alwaysShow: true, // will always show the root menu
    name: 'Permission',
    meta: {
      title: '超级管理员',
      icon: 'lock',
      roles: ['admin'] // you can set roles in root nav
    },
    hidden: true,
    children: [
      {
        path: 'user1',
        component: () => import('@/views/user/index'),
        name: 'user',
        meta: {
          title: '省代管理',
          roles: ['admin']// if do not set roles, means: this page does not require permission
        },
        hidden: true

      },
      // {
      //   path: 'zongZhang',
      //   component: () => import('@/views/zongZhang/index'),
      //   name: 'zongZhang',
      //   meta: {
      //     title: '系统总账',
      //     roles: ['admin']// if do not set roles, means: this page does not require permission
      //   }
      // },
      // {
      //   path: 'totalDayAccount',
      //   component: () => import('@/views/totalDayAccount/index'),
      //   name: 'totalDayAccount',
      //   meta: {
      //     title: '系统日记账',
      //     roles: ['admin']// if do not set roles, means: this page does not require permission
      //   }
      // },
      // {
      //   path: 'pfTransfer',
      //   component: () => import('@/views/pfTransfer/index'),
      //   name: 'pfTransfer',
      //   meta: {
      //     title: '浦发转账记录',
      //     roles: ['admin']// if do not set roles, means: this page does not require permission
      //   }
      // },
      // {
      //   path: 'verify',
      //   component: () => import('@/views/verify/index'),
      //   name: 'verify',
      //   meta: {
      //     title: '系统日对账',
      //     roles: ['admin']// if do not set roles, means: this page does not require permission
      //   }
      // },
      {
        path: 'doSet',
        component: () => import('@/views/doSet/index'),
        name: 'doSet',
        meta: {
          title: '平台设置',
          roles: ['admin'] // or you can only set roles in sub nav
        },
        hidden: true

      },
      // {
      //   path: 'alarm',
      //   component: () => import('@/views/alarm/index'),
      //   name: 'alarm',
      //   meta: {
      //     title: '告警信息',
      //     roles: ['admin'] // or you can only set roles in sub nav
      //   }
      // },
      {
        path: 'codeManage',
        component: () => import('@/views/codeManage/index'),
        name: 'codeManage',
        meta: {
          title: '验证码',
          roles: ['admin'] // or you can only set roles in sub nav
        },
        hidden: true

      }
    ]
  },

  // {
  //   path: '/icon',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/svg-icons/index'),
  //       name: 'Icons',
  //       meta: { title: 'icons', icon: 'icon', noCache: true }
  //     }
  //   ]
  // },

  /** when your routing map is too long, you can split it into small modules **/
  // componentsRouter,
  // chartsRouter,
  // nestedRouter,
  // tableRouter,

  // {
  //   path: '/example',
  //   component: Layout,
  //   redirect: '/example/list',
  //   name: 'Example',
  //   meta: {
  //     title: 'example',
  //     icon: 'example'
  //   },
  //   children: [
  //     {
  //       path: 'create',
  //       component: () => import('@/views/example/create'),
  //       name: 'CreateArticle',
  //       meta: { title: 'createArticle', icon: 'edit' }
  //     },
  //     {
  //       path: 'edit/:id(\\d+)',
  //       component: () => import('@/views/example/edit'),
  //       name: 'EditArticle',
  //       meta: { title: 'editArticle', noCache: true, activeMenu: '/example/list' },
  //       hidden: true
  //     },
  //     {
  //       path: 'list',
  //       component: () => import('@/views/example/list'),
  //       name: 'ArticleList',
  //       meta: { title: 'articleList', icon: 'list' }
  //     }
  //   ]
  // },

  // {
  //   path: '/tab',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/tab/index'),
  //       name: 'Tab',
  //       meta: { title: 'tab', icon: 'tab' }
  //     }
  //   ]
  // },

  // {
  //   path: '/error',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   name: 'ErrorPages',
  //   meta: {
  //     title: 'errorPages',
  //     icon: '404'
  //   },
  //   children: [
  //     {
  //       path: '401',
  //       component: () => import('@/views/error-page/401'),
  //       name: 'Page401',
  //       meta: { title: 'page401', noCache: true }
  //     },
  //     {
  //       path: '404',
  //       component: () => import('@/views/error-page/404'),
  //       name: 'Page404',
  //       meta: { title: 'page404', noCache: true }
  //     }
  //   ]
  // },

  // {
  //   path: '/error-log',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   children: [
  //     {
  //       path: 'log',
  //       component: () => import('@/views/error-log/index'),
  //       name: 'ErrorLog',
  //       meta: { title: 'errorLog', icon: 'bug' }
  //     }
  //   ]
  // },

  // {
  //   path: '/excel',
  //   component: Layout,
  //   redirect: '/excel/export-excel',
  //   name: 'Excel',
  //   meta: {
  //     title: 'excel',
  //     icon: 'excel'
  //   },
  //   children: [
  //     {
  //       path: 'export-excel',
  //       component: () => import('@/views/excel/export-excel'),
  //       name: 'ExportExcel',
  //       meta: { title: 'exportExcel' }
  //     },
  //     {
  //       path: 'export-selected-excel',
  //       component: () => import('@/views/excel/select-excel'),
  //       name: 'SelectExcel',
  //       meta: { title: 'selectExcel' }
  //     },
  //     {
  //       path: 'export-merge-header',
  //       component: () => import('@/views/excel/merge-header'),
  //       name: 'MergeHeader',
  //       meta: { title: 'mergeHeader' }
  //     },
  //     {
  //       path: 'upload-excel',
  //       component: () => import('@/views/excel/upload-excel'),
  //       name: 'UploadExcel',
  //       meta: { title: 'uploadExcel' }
  //     }
  //   ]
  // },

  // {
  //   path: '/zip',
  //   component: Layout,
  //   redirect: '/zip/download',
  //   alwaysShow: true,
  //   name: 'Zip',
  //   meta: { title: 'zip', icon: 'zip' },
  //   children: [
  //     {
  //       path: 'download',
  //       component: () => import('@/views/zip/index'),
  //       name: 'ExportZip',
  //       meta: { title: 'exportZip' }
  //     }
  //   ]
  // },

  // {
  //   path: '/pdf',
  //   component: Layout,
  //   redirect: '/pdf/index',
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/pdf/index'),
  //       name: 'PDF',
  //       meta: { title: 'pdf', icon: 'pdf' }
  //     }
  //   ]
  // },
  // {
  //   path: '/pdf/download',
  //   component: () => import('@/views/pdf/download'),
  //   hidden: true
  // },

  // {
  //   path: '/theme',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/theme/index'),
  //       name: 'Theme',
  //       meta: { title: 'theme', icon: 'theme' }
  //     }
  //   ]
  // },

  // {
  //   path: '/clipboard',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/clipboard/index'),
  //       name: 'ClipboardDemo',
  //       meta: { title: 'clipboardDemo', icon: 'clipboard' }
  //     }
  //   ]
  // },

  // {
  //   path: '/i18n',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/i18n-demo/index'),
  //       name: 'I18n',
  //       meta: { title: 'i18n', icon: 'international' }
  //     }
  //   ]
  // },

  // {
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'https://github.com/PanJiaChen/vue-element-admin',
  //       meta: { title: 'externalLink', icon: 'link' }
  //     }
  //   ]
  // },

  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
